package com.sos.activity;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.sos.R;
import com.sos.service.SetManager;
import com.sos.vo.SetInfo;
/***
 * 设置界面
 * **/
public class SetActivity extends Activity {
	SetManager setManager;
	SetInfo setinfo=new SetInfo();
	EditText sos_phone;
	EditText my_hone;
	EditText my_name;
	EditText defalut_email;
	EditText www_ip;
	EditText www_port;
	Button save_btn;
	
	/**
	 * @see android.app.Activity#onCreate(Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// TODO Put your code here
		setManager=new SetManager(this);
		setContentView(R.layout.set);
		
		sos_phone=(EditText)findViewById(R.id.sos_phone);
		my_hone=(EditText)findViewById(R.id.my_hone);
		my_name=(EditText)findViewById(R.id.my_name);
		defalut_email=(EditText)findViewById(R.id.defalut_email);
		www_ip=(EditText)findViewById(R.id.www_ip);
		www_port=(EditText)findViewById(R.id.www_port);
		save_btn=(Button)findViewById(R.id.saveBtn);
		
		
		setinfo=setManager.get();//读取设置信息
		sos_phone.setText(setinfo.getSos_phone());
		my_hone.setText(setinfo.getMy_hone());
		my_name.setText(setinfo.getMy_name());
		defalut_email.setText(setinfo.getDefalut_email());
		www_ip.setText(setinfo.getWww_ip());
		www_port.setText(setinfo.getWww_port());
		
		save_btn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				//保存设置信息，然后调整到主界面
				SetInfo info=new SetInfo(
						sos_phone.getText().toString(),my_hone.getText().toString(),my_name.getText().toString(),
						defalut_email.getText().toString(),www_ip.getText().toString(),www_port.getText().toString());
				setManager.save(info);
				Intent setIntent = new Intent();
				setIntent.setClass(SetActivity.this, MainActivity.class);
				startActivity(setIntent);
			}
		});
	}
}
